package com.lktx.sso.admin.entity;

import com.lktx.sso.admin.dto.KvDTO;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.core.handler.JacksonTypeHandler;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;

/** oidc配置表 - sso_app_oidc_config */
@Data
@Table("sso_app_oidc_config")
public class SsoAppOidcConfig {
    /** APP ID*/
    @Id(value = "sso_app_id", keyType = KeyType.None)
    private Integer ssoAppId;
    /**授权类型*/
    @Column(typeHandler = JacksonTypeHandler.class)
    private Set<String> authGrantTypes;
    /**响应类型*/
    private String responseTypes;
    /** 重定向URIs*/
    private String redirectUris;
    /**登出重定向URIs*/
    private String postLogoutRedirectUris;
    /**scopes*/
    @Column(typeHandler = JacksonTypeHandler.class)
    private Set<String> grantScopes;
    /**是否需要授权同意*/
    private Boolean requireAuthConsent;
    /**需要PKCE*/
    private Boolean requireProofKey;
    /**令牌 Endpoint 身份验证签名算法*/
    private String tokenEndpointAuthSigningAlgorithm;
    /**刷新 Token生存时间（分钟）*/
    private Integer refreshTokenTimeToLive;
    /**授权码 生存时间（分钟）*/
    private Integer authorizationCodeTimeToLive;
    /**设备CODE 生存时间（分钟）*/
    private Integer deviceCodeTimeToLive;
    /**ID Token生存时间（分钟）*/
    private Integer idTokenTimeToLive;
    /**访问 Token生存时间（分钟）*/
    private Integer accessTokenTimeToLive;
    /**Id Token 签名算法*/
    private String idTokenSignatureAlgorithm;
    /**Access Token 格式*/
    private String accessTokenFormat;
    /**是否重用刷新令牌*/
    private Boolean reuseRefreshToken;
    /**
     * 私钥
     */
    private String privateKey;
    /**
     * 公钥
     */
    private String publicKey;

    /**
     * jwt负荷
     */
    @Column(typeHandler = JacksonTypeHandler.class)
    private List<KvDTO> jwtPayload;

    /**
     * jwtheader
     */
    @Column(typeHandler = JacksonTypeHandler.class)
    private List<KvDTO>  jwtHeader;

    /**创建时间*/
    @Column(onInsertValue = "now()")
    private LocalDateTime createTime;
    /**更新时间*/
    @Column(onUpdateValue = "now()", onInsertValue = "now()")
    private LocalDateTime updateTime;
}